<div class="flex flex-col gap-6">
    <!-- 积分规则管理 -->
    <div class="bg-white rounded-xl shadow-md p-6">
        <div class="flex justify-between items-center mb-6">
            <h2 class="text-2xl font-bold">积分规则管理</h2>
            <button class="btn btn-primary" id="createRuleBtn">
                <i class="fa fa-plus mr-2"></i> 新建规则
            </button>
        </div>
        
        <div class="overflow-x-auto">
            <table class="min-w-full divide-y divide-gray-200">
                <thead class="bg-gray-50">
                    <tr>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">规则名称</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">规则类型</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">积分值</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">状态</th>
                        <th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase">操作</th>
                    </tr>
                </thead>
                <tbody class="bg-white divide-y divide-gray-200" id="rulesTable">
                    <!-- 规则数据动态加载 -->
                </tbody>
            </table>
        </div>
    </div>
    
    <!-- 积分排行榜 -->
    <div class="bg-white rounded-xl shadow-md p-6">
        <h2 class="text-2xl font-bold mb-6">积分排行榜</h2>
        
        <div class="grid grid-cols-1 md:grid-cols-3 gap-6" id="leaderboard">
            <!-- 排行榜数据动态加载 -->
        </div>
    </div>
    
    <!-- 积分记录查询 -->
    <div class="bg-white rounded-xl shadow-md p-6">
        <div class="flex justify-between items-center mb-6">
            <h2 class="text-2xl font-bold">积分记录查询</h2>
            <div class="flex gap-3">
                <div class="relative">
                    <input type="text" id="searchUserId" class="form-input pl-10" placeholder="用户ID">
                    <i class="fa fa-search absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"></i>
                </div>
                <button class="btn btn-primary" id="searchRecordsBtn">查询</button>
            </div>
        </div>
        
        <div class="overflow-x-auto">
            <table class="min-w-full divide-y divide-gray-200">
                <thead class="bg-gray-50">
                    <tr>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">用户</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">规则</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">积分</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">描述</th>
                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">时间</th>
                    </tr>
                </thead>
                <tbody class="bg-white divide-y divide-gray-200" id="recordsTable">
                    <!-- 记录数据动态加载 -->
                </tbody>
            </table>
        </div>
        
        <!-- 分页控件 -->
        <div class="mt-6 flex justify-between items-center">
            <div class="text-sm text-gray-500">显示 <span id="startRow">1</span> 到 <span id="endRow">10</span> 条，共 <span id="totalRows">100</span> 条</div>
            <div class="flex space-x-2">
                <button class="btn btn-outline" id="prevPageBtn">上一页</button>
                <button class="btn btn-outline" id="nextPageBtn">下一页</button>
            </div>
        </div>
    </div>
</div>

<!-- 积分规则编辑模态框 -->
<div id="ruleModal" class="fixed inset-0 bg-black bg-opacity-50 hidden items-center justify-center z-50">
    <div class="bg-white rounded-lg w-full max-w-2xl p-6">
        <div class="flex justify-between items-center mb-4">
            <h3 class="text-xl font-bold" id="modalTitle">新建积分规则</h3>
            <button id="closeModalBtn" class="text-gray-500 hover:text-gray-700">
                <i class="fa fa-times"></i>
            </button>
        </div>
        
        <form id="ruleForm">
            <input type="hidden" id="ruleId">
            
            <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">规则名称</label>
                    <input type="text" id="ruleName" class="form-input w-full" required>
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">规则类型</label>
                    <input type="text" id="ruleType" class="form-input w-full" required>
                </div>
            </div>
            
            <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">积分值</label>
                    <input type="number" id="pointValue" class="form-input w-full" min="1" required>
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">状态</label>
                    <select id="isActive" class="form-select w-full">
                        <option value="true">启用</option>
                        <option value="false">禁用</option>
                    </select>
                </div>
            </div>
            
            <div class="mb-4">
                <label class="block text-sm font-medium text-gray-700 mb-1">规则描述</label>
                <textarea id="description" class="form-textarea w-full" rows="3"></textarea>
            </div>
            
            <div class="flex justify-end space-x-3">
                <button type="button" id="cancelBtn" class="btn btn-outline">取消</button>
                <button type="submit" class="btn btn-primary">保存</button>
            </div>
        </form>
    </div>
</div>

<!-- 积分奖励模态框 -->
<div id="awardModal" class="fixed inset-0 bg-black bg-opacity-50 hidden items-center justify-center z-50">
    <div class="bg-white rounded-lg w-full max-w-md p-6">
        <div class="flex justify-between items-center mb-4">
            <h3 class="text-xl font-bold">奖励积分</h3>
            <button class="close-award-modal text-gray-500 hover:text-gray-700">
                <i class="fa fa-times"></i>
            </button>
        </div>
        
        <form id="awardForm">
            <div class="mb-4">
                <label class="block text-sm font-medium text-gray-700 mb-1">用户ID</label>
                <input type="number" id="awardUserId" class="form-input w-full" required>
            </div>
            
            <div class="mb-4">
                <label class="block text-sm font-medium text-gray-700 mb-1">奖励方式</label>
                <div class="flex gap-3">
                    <label class="inline-flex items-center">
                        <input type="radio" name="awardType" value="rule" checked class="form-radio">
                        <span class="ml-2">按规则奖励</span>
                    </label>
                    <label class="inline-flex items-center">
                        <input type="radio" name="awardType" value="custom" class="form-radio">
                        <span class="ml-2">自定义奖励</span>
                    </label>
                </div>
            </div>
            
            <div id="ruleAwardSection">
                <div class="mb-4">
                    <label class="block text-sm font-medium text-gray-700 mb-1">选择规则</label>
                    <select id="ruleSelect" class="form-select w-full">
                        <!-- 规则选项动态加载 -->
                    </select>
                </div>
            </div>
            
            <div id="customAwardSection" class="hidden">
                <div class="mb-4">
                    <label class="block text-sm font-medium text-gray-700 mb-1">积分值</label>
                    <input type="number" id="customPoints" class="form-input w-full" min="1">
                </div>
                <div class="mb-4">
                    <label class="block text-sm font-medium text-gray-700 mb-1">规则类型</label>
                    <input type="text" id="customRuleType" class="form-input w-full">
                </div>
            </div>
            
            <div class="mb-4">
                <label class="block text-sm font-medium text-gray-700 mb-1">奖励原因</label>
                <textarea id="awardReason" class="form-textarea w-full" rows="2" required></textarea>
            </div>
            
            <div class="flex justify-end space-x-3">
                <button type="button" class="close-award-modal btn btn-outline">取消</button>
                <button type="submit" class="btn btn-primary">确认奖励</button>
            </div>
        </form>
    </div>
</div>